import requests
import parsel

url = 'https://yys.163.com/media/picture.html'

headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'
}
resp = requests.get(url, headers=headers)
data_html = resp.text
selector = parsel.Selector(data_html)
# body > div.main.picture > div.wrap > div.scroll > div.part-2.animate > div.tab-cont.active > div > div > div > a:nth-child(6)
jpg_list = selector.css('.tab-cont .item .cover .mask a:nth-child(6)::attr(href)').getall()
# print(jpg_list)
for img_url in jpg_list:
    title = img_url.split('/')[8:]
    title = ''.join(title)
    resp_1 = requests.get(img_url, headers=headers).content
    with open(f'img/{title}', mode='wb') as f:
        f.write(resp_1)
        print(f'{title}保存成功！！！！')

print('完成！！！！！！！！！！！！！！！！！')